package com.cloud.base.thread;

import lombok.SneakyThrows;

import java.util.concurrent.locks.LockSupport;

public class LockSupportMain {

    // 相当于wait notify
    @SneakyThrows
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            LockSupportMain.del();

        });
        thread.start();
        Thread.sleep(2000);
        LockSupport.unpark(thread);
    }

    @SneakyThrows
    public static void del() {
        System.out.println("del执行开始:" + Thread.currentThread().getName());
        LockSupport.park();
        Thread.sleep(5000);
        System.out.println("del执行结束:" + Thread.currentThread().getName());
    }
}
